package servlet;

import dao.CourseDao;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by ssw on 2018/6/12.
 */
public class AddCourseServlet extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String cname=new String(req.getParameter("cname").getBytes("ISO-8859-1"),"UTF-8");
        CourseDao courseDao =new CourseDao();
        boolean res= courseDao.addCourse(cname);
        if(res)
            req.getRequestDispatcher("sgms/admin_addCourse.jsp?flag=1").forward(req, resp);
        else
            req.getRequestDispatcher("sgms/admin_addCourse.jsp?flag=0").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        
    }
}
